aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/(profile)
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/(app)/[username]/(profile)')
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.svelte4
-rw-r--r--src/routes/(app)/[username]/(profile)/+page.svelte163
2 files changed, 3 insertions, 164 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte
index 0520f1b8..3d4f191b 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.svelte
+++ b/src/routes/(app)/[username]/(profile)/+layout.svelte
@@ -149,7 +149,7 @@
</a>
{/if}
- {#if !subject.anon && subject.username !== user?.username && !subject.hidepay}
+ {#if !subject.anon && subject.username !== user?.username}
<a
href={user
? `/pay/${subject.username}`
@@ -168,7 +168,6 @@
</a>
{/if}
- {#if user?.username !== subject.username}
<button
type="button"
on:click={toggleDetails}
@@ -177,7 +176,6 @@
<Icon icon="profile" style="w-8 mr-2" />
<div class="mt-1">{$t("user.info")}</div>
</button>
- {/if}
{#if user?.admin && user.username !== subject.username}
<form class="w-full flex" on:submit|preventDefault={reset}>
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte
index 5878d252..c74f8e6d 100644
--- a/src/routes/(app)/[username]/(profile)/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/+page.svelte
@@ -1,22 +1,9 @@
<script>
+ import { btc, f, sat, post } from "$lib/utils";
import { browser } from "$app/environment";
import { goto, invalidate } from "$app/navigation";
- import { btc, f, sat, post } from "$lib/utils";
import Icon from "$comp/Icon.svelte";
- import Balance from "$comp/Balance.svelte";
- import DeleteItem from "$comp/DeleteItem.svelte";
import { t } from "$lib/translations";
- import { fade } from "svelte/transition";
- import { cubicIn } from "svelte/easing";
- import { flip } from "svelte/animate";
- import { installPrompt } from "$lib/store";
-
- import {
- dndzone,
- SHADOW_ITEM_MARKER_PROPERTY_NAME,
- SOURCES,
- TRIGGERS,
- } from "svelte-dnd-action";
export let data;
@@ -28,8 +15,6 @@
$: rate = rates[currency];
$: refresh(data);
let refresh = (d) => ({ items, subject, user, rates } = d);
- let dragDisabled =
- subject?.id !== user?.id || (browser && window.innerWidth < 768);
let deleting;
$: total = items.reduce((a, b) => a + b.price * b.quantity, 0);
@@ -37,40 +22,6 @@
deleting = item;
};
- function handleConsider(e) {
- const {
- items: newItems,
- info: { source, trigger },
- } = e.detail;
- items = newItems;
- if (source === SOURCES.KEYBOARD && trigger === TRIGGERS.DRAG_STOPPED)
- reset();
- }
-
- async function handleFinalize(e) {
- const {
- items: newItems,
- info: { source },
- } = e.detail;
- items = newItems;
- if (source === SOURCES.POINTER) reset();
-
- if (subject?.id === user?.id) {
- await post("/api/items/sort", { items });
- invalidate("app:items");
- }
- }
-
- function startDrag(e) {
- e.preventDefault();
- dragDisabled = false;
- }
-
- function handleKeyDown(e) {
- if ((e.key === "Enter" || e.key === " ") && dragDisabled)
- dragDisabled = false;
- }
-
$: if (total > 0 && browser) {
let payButton = document.querySelector("#payButton");
if (payButton) payButton.addEventListener("click", checkout);
@@ -98,82 +49,12 @@
if (user) goto(`/send/invoice/${id}`, { invalidateAll: true });
else goto(`/${subject.username}/invoice/${id}`);
};
-
- let reset = () =>
- (dragDisabled =
- user?.username !== subject?.username || window.innerWidth < 768);
-
- let install = async () => {
- if (!$installPrompt) return;
- await $installPrompt.prompt();
- $installPrompt = null;
- };
</script>
-<svelte:window on:resize={reset} />
-
-{#if deleting}
- <DeleteItem bind:item={deleting} />
-{/if}
-
<div class="space-y-5">
- {#if user?.id === subject.id}
- <div class="flex justify-center lg:justify-start">
- <Balance {user} {rate} />
- </div>
-
- {#if !user.balance}
- <div class="mb-8">
- <p class="text-secondary text-lg">
- {$t("user.welcome")}
- </p>
- </div>
- {/if}
-
- <div class="flex flex-wrap gap-3 justify-center w-full text-xl">
- <a href={`/send`} class="contents grow">
- <button
- type="button"
- class="rounded-2xl border py-5 px-6 font-bold hover:opacity-80 flex bg-primary grow"
- >
- <div class="mx-auto flex gap-2">
- <Icon icon="send" style="w-8" />
- <div class="my-auto">{$t("user.dashboard.send")}</div>
- </div>
- </button>
- </a>
-
- <a href={`/${user.username}/receive`} class="contents">
- <button
- class="rounded-2xl border py-5 px-6 font-bold hover:opacity-80 flex bg-primary grow"
- >
- <div class="mx-auto flex gap-2">
- <Icon icon="numpad" style="w-8" />
- <div class="my-auto">{$t("user.dashboard.receive")}</div>
- </div>
- </button>
- </a>
-
- {#if $installPrompt}
- <button
- class="rounded-2xl border py-5 px-6 font-bold hover:opacity-80 flex bg-black text-white grow basis-full fixed bottom-16 xl:hidden"
- on:click={install}
- >
- <div class="mx-auto flex gap-2">
- <Icon icon="save" style="w-8 mx-auto invert" />
- <div class="my-auto text-xl whitespace-nowrap">{$t("user.install")}</div>
- </div>
- </button>
- {/if}
- </div>
- {/if}
-
<div
class="grid sm:grid-cols-2 gap-4"
class:pb-20={total > 0}
- use:dndzone={{ items, flipDurationMs, dropTargetStyle, dragDisabled }}
- on:consider={handleConsider}
- on:finalize={handleFinalize}
>
{#each items as i (i.id)}
<button
@@ -182,12 +63,7 @@
on:click={() => i.quantity++}
>
<div class="relative w-full h-64 overflow-hidden rounded-xl">
- {#if i[SHADOW_ITEM_MARKER_PROPERTY_NAME]}
- <div
- in:fade={{ duration: 200, easing: cubicIn }}
- class="custom-shadow-item"
- />
- {:else if i.image}
+ {#if i.image}
<img
src={`/api/public/${i.image}.webp`}
alt={i.name}
@@ -199,41 +75,6 @@
alt="Banner"
/>
{/if}
- {#if user?.username === subject.username}
- <div class="flex gap-2 justify-center absolute top-2 right-2">
- <button type="button" on:click|stopPropagation={() => {}}>
- <a href={`/${user.username}/items/${i.id}`}>
- <button
- class="bg-black rounded-full w-12 h-12 bg-opacity-40 hover:bg-opacity-100"
- >
- <Icon icon="edit" style="w-8 mx-auto invert" />
- </button>
- </a>
- </button>
- <button
- class="bg-black rounded-full w-12 h-12 bg-opacity-40 hover:bg-opacity-100"
- on:click|stopPropagation={() => del(i)}
- >
- <Icon icon="trash" style="w-8 mx-auto invert" />
- </button>
- <button
- type="button"
- on:click|stopPropagation={() => {}}
- class="sm:hidden"
- on:mousedown={startDrag}
- on:touchstart={startDrag}
- on:keydown={handleKeyDown}
- >
- <a href={`/${user.username}/items/${i.id}`}>
- <button
- class="bg-black rounded-full w-12 h-12 bg-opacity-40 hover:bg-opacity-100"
- >
- <Icon icon="move" style="w-8 mx-auto invert" />
- </button>
- </a>
- </button>
- </div>
- {/if}
</div>
<div class="bg-white rounded-xl py-2">
<div class="flex text-left gap-2">